﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Web.Admin.ashx
{
    /// <summary>
    /// visualedit 的摘要说明
    /// 可视化编辑请求地址
    /// </summary>
    public class visualedit : Evan.WebUI.ManagerAshxHelper
    {

        public override void ProcessRequest(HttpContext context)
        {
            string action = Evan.Common.CommFun.GetQueryString("action");

            if (!IsAdminLogin())
            {
                JsonResult(context, -99, "管理员未登陆");
            }
            else
            {
                switch (action)
                {
                    case "vEdit":
                        vEditor(context);
                        break;
                    default:
                        break;
                }
            }
        }

        public void vEditor(HttpContext context)
        {
            string FieldListStr = GetParam("FieldList");
            FieldListStr = Evan.Common.TransCode.StrDeCode(FieldListStr);

            List<Evan.Plugins.VisualEdit.vEditItemModel> FieldList = Evan.Common.JsonHelper.JsonToList<Evan.Plugins.VisualEdit.vEditItemModel>(FieldListStr);

            if (FieldList.Count > 0)
            {
                bool isok = Evan.Plugins.VisualEdit.vEditorExec(FieldList);
                JsonResult(context, isok ? 1 : 0, "操作完成");
            }
            else
            {
                JsonResult(context, -1, "无内容可编辑");
            }
        }
        
    }
}